package 上海理工大学;

import com.alibaba.excel.EasyExcel;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class SH_u {
    public static void main(String[] args) throws IOException {
        SH_uBean shUBean ;
        List<SH_uBean> shUBeans = new ArrayList<>();
        Connection connect = Jsoup.connect("https://me.usst.edu.cn/js_12247/list.htm");
        Document post = connect.post();
        for (Element newsListList2 : post.getElementsByClass("news_list list2")) {
            for (Element element : newsListList2.getElementsByTag("a")) {
                shUBean = new SH_uBean();
                System.out.println(element.text());
                String Url = "https://me.usst.edu.cn/" + element.attr("href");
                System.out.println(Url);
                shUBean.setT_name(element.text());
                shUBean.setUrl(Url);
                shUBeans.add(shUBean);
            }
        }

        EasyExcel.write("src/SHu.xlsx", SH_uBean.class).sheet("user").doWrite(shUBeans);

    }

}
